import React from 'react';
import { Popconfirm, message } from 'antd';
import axios from 'axios';

const Confirm = props => {

    const confirm = () => {
        axios({
            method: props.method || 'get',
            url: props.url,
            data: props.data
        }).then(res => {
            if(res.success){
                message.success(res.data);
                props.research()
            }else{
                message.error(res.message)
            }
        })
    };

    const cancel = () => {

    };

    return (
        <>
            <Popconfirm
                placement="topRight"
                title="此操作不可逆，你还要继续吗?"
                onConfirm={confirm}
                onCancel={cancel}
                okText="确认"
                cancelText="取消"
            >{props.children}</Popconfirm>
        </>
    )
};

export default Confirm;